package com.cyys.modules.system.model.org;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cyys.common.utils.StringUtil;
import com.cyys.modules.core.model.CoreBean;
import com.cyys.modules.core.sysParam.OrgUtil;
import com.cyys.modules.core.sysParam.ParamBasicUtil;
import com.cyys.modules.core.sysParam.ParamConstants;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

@Data
@TableName("sys_org_notice")
public class OrgNotice extends CoreBean {

    private String orgId;  //所在单位编号

    @TableField(condition = SqlCondition.LIKE)
    private String title; //通知标题

    private String type;  //类型

    private String content;  //通知内容

    @TableField(updateStrategy= FieldStrategy.NOT_NULL)
    private String attachments;  //附件

    private Long userRead;//已读人数

    @JsonIgnore
    public String getOrgName() {
        if(StringUtil.isNotEmpty(orgId)  && OrgUtil.get(orgId)!= null)
            return OrgUtil.get(orgId).getName();
        return "";
    }

    @JsonIgnore
    public String getTypeName() {
        if(StringUtil.isNotEmpty(type))
            return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.NOTICE_TYPE).get(type);
        return null;
    }
}
